﻿using System;
using System.Windows;
using System.Windows.Controls;

namespace SharpDepend.WPF.Controls
{
    /// <summary>
    /// Interaction logic for TextInput.xaml
    /// </summary>
    public partial class TextInput : UserControl
    {
        public TextInput()
        {
            InitializeComponent();
        }
        public string Label
        {
            get
            {
                return this.HeaderLabel.Text;
            }
            set
            {
                this.HeaderLabel.Text = value;
            }
        }

        public string Text
        {
            get
            {
                return this.TextBox.Text;
            }
            set
            {
                this.TextBox.Text = value;
            }
        }
        
        private void button_Click(object sender, RoutedEventArgs e)
        {
            Action action = this.RequestClose;
            if (action == null)
            {
                return;
            }
            action();
        }

        public event Action RequestClose;

        public event TextChangedEventHandler TextChanged
        {
            add
            {
                this.TextBox.TextChanged += value;
            }
            remove
            {
                this.TextBox.TextChanged -= value;
            }
        }
    }
}
